import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Home from '../pages/Home'
import Shop from '../pages/Shop'
import PageNotFound from '../pages/NotFound'
import Learn from '../pages/Learn'
import WebLearn from "../pages/Learn/subpages/WebLearn";
import JavaLearn from "../pages/Learn/subpages/JavaLearn";

Vue.use(Router)

export default new Router({
  //history 模式  去除路由前边的 # （配置该history模式后，需要nginx后端进行相对应的配置，详见官方文档）
  mode: 'history',
  routes: [
    // {
    //   path: '/',
    //   name: 'HelloWorld',
    //   component: HelloWorld
    // },
    //重定向
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: "/home",
      name: 'Home',
      component: Home
    },
    {
      path: "/shop/:id",
      name: 'Shop',
      props: true,
      component: Shop
    },
    {
      path: "/learn",
      name: 'Learn',
      component: Learn,
      redirect: '/learn/web-learn',
      children: [
        {
          path: "web-learn",
          component: WebLearn
        },
        {
          path: "java-learn",
          component: JavaLearn
        }
      ]
    },
    //捕获所有路由或404路由
    {
      path: "*",
      name: "404",
      component: PageNotFound
    }
  ]
})
